﻿package mortal.game.view.chat.chatPrivate
{
    import Message.Public.*;
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import flash.display.*;
    import flash.text.*;
    import mortal.common.global.*;
    import mortal.common.tools.*;
    import mortal.component.gconst.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.layer3D.utils.*;
    import mortal.game.utils.*;
    import mortal.game.view.chat.chatPanel.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.menu.*;

    public class ChatTimeItem extends Sprite
    {
        private var _headImage:GImageBitmap;
        private var _vipImg:GImageBitmap;
        private var _textFieldTime:TextField;
        private var _talkBg:ScaleBitmap;
        private var _chatItem:ChatItem;

        public function ChatTimeItem(param1:ChatItem, param2:ChatData)
        {
            this._chatItem = param1;
            this.init(param1, param2);
            return;
        }// end function

        private function init(param1:ChatItem, param2:ChatData) : void
        {
            var _loc_3:Boolean = false;
            var _loc_7:String = null;
            var _loc_23:TextField = null;
            var _loc_25:String = null;
            _loc_3 = param2.sChatMsg.chatType == EChatType._EChatTypeGuildRoll || param2.alyzType == 1;
            var _loc_4:* = param2.date;
            var _loc_5:* = !EntityUtil.isSameServerByRole(param2.fromMiniPlayer.entityId);
            var _loc_6:* = param2.fromMiniPlayer.VIP > 0 && param2.fromMiniPlayer.VIP <= 10;
            if (!_loc_5)
            {
                _loc_7 = param2.fromMiniPlayer.name;
            }
            else
            {
                _loc_7 = NameUtil.getProxyName(param2.fromMiniPlayer.entityId, true) + param2.fromMiniPlayer.name;
            }
            var _loc_8:* = AvatarUtil.getPlayerAvatarUrl(param2.fromMiniPlayer.career, param2.fromMiniPlayer.sex, AvatarUtil.Small);
            var _loc_9:* = param2.isSelfMsg();
            var _loc_10:* = param1.height + 6;
            var _loc_11:* = _loc_10 + 20;
            var _loc_12:Number = 5;
            var _loc_13:Number = 0;
            var _loc_14:Number = 53;
            var _loc_15:Number = 15;
            var _loc_16:* = param1.width + 30;
            if (_loc_16 < 55)
            {
                _loc_16 = 55;
            }
            var _loc_17:Number = 56;
            var _loc_18:Number = -4;
            var _loc_19:Number = 71;
            var _loc_20:Number = 16;
            if (_loc_3)
            {
                _loc_19 = 59;
                _loc_20 = 18;
            }
            var _loc_21:* = ImagesConst.ChatOtherTalkBg;
            if (_loc_9)
            {
                _loc_14 = 293 - _loc_16;
                _loc_12 = 293;
                _loc_17 = 236;
                if (!_loc_3)
                {
                    _loc_19 = _loc_14 + 10;
                }
                else
                {
                    _loc_19 = _loc_14 + 15;
                }
                _loc_21 = ImagesConst.ChatSelfTalkBg;
            }
            var _loc_22:* = new Sprite();
            UIFactory.setObjAttri(_loc_22, _loc_12 - 3, _loc_13 - 3, -1, -1, this);
            UIFactory.gBitmap("FriendHeadBg", 0, 0, _loc_22);
            PlayerMenuRegister.Register(_loc_22, param2.fromMiniPlayer);
            this._headImage = UIFactory.gImageBitmap(_loc_8, _loc_12, _loc_13, this);
            if (_loc_6)
            {
                _loc_25 = GameDefConfig.instance.getVipLevelIconUrl(param2.fromMiniPlayer.VIP);
                this._vipImg = UIFactory.gImageBitmap(_loc_25, _loc_12 - 2, _loc_13 - 2, this);
            }
            _loc_23 = new TextField();
            _loc_23.height = 22;
            _loc_23.autoSize = TextFieldAutoSize.LEFT;
            _loc_23.selectable = false;
            _loc_23.filters = [FilterConst.glowFilter];
            _loc_23.defaultTextFormat = GlobalStyle.textFormatHuang.setSize(10);
            var _loc_24:* = HTMLUtil.addColor(DateParser.parse(_loc_4, "hh:mm:ss"), GlobalStyle.colorHui);
            if (!_loc_9)
            {
                if (param2.guildPost > 3)
                {
                    _loc_24 = HTMLUtil.addColor("[" + GameDefConfig.instance.getGuildPositonHtmlName(param2.guildPost, false, false) + "·" + _loc_7 + "]&nbsp;" + _loc_24, GlobalStyle.colorHui);
                }
                else
                {
                    _loc_24 = HTMLUtil.addColor(_loc_7 + "&nbsp;" + _loc_24, GlobalStyle.colorHui);
                }
            }
            _loc_23.htmlText = _loc_24;
            _loc_23.y = _loc_18;
            _loc_23.x = _loc_17;
            this.addChild(_loc_23);
            if (!_loc_3)
            {
                this._talkBg = UIFactory.bg(_loc_14, _loc_15, _loc_16, _loc_10, this, _loc_21);
            }
            param1.y = _loc_20;
            param1.x = _loc_19;
            this.addChild(param1);
            return;
        }// end function

        override public function get height() : Number
        {
            return 26 + this._chatItem.height;
        }// end function

        public function dispose() : void
        {
            this._chatItem.dispose();
            return;
        }// end function

    }
}
